<?php


namespace app\common\model;


use think\Model;
use think\model\concern\SoftDelete;

/**
 * 基础模型基类
 * Class BaseModel
 * @package app\api\model
 *
 * @Author: Li Guo Xin <guoxinlee129@gmail.com>
 * @Date: 2020/7/8
 * @Time: 10:29
 */
class CommonModel extends Model
{
    use SoftDelete;
    protected $defaultSoftDelete = '0000-00-00 00:00:00';
    protected $hidden            = ['delete_time'];

    public function setCreateTimeAttr($timestamp)
    {
        return date('Y-m-d H:i:s', $timestamp);
    }

    public function setUpdateTimeAttr($timestamp)
    {
        return date('Y-m-d H:i:s', $timestamp);
    }

    public function getUpdateTimeAttr($v)
    {
        return $v === '0000-00-00 00:00:00' ? '' : $v;
    }

    public function setDeleteTimeAttr($timestamp)
    {
        return date('Y-m-d H:i:s', $timestamp);
    }
}